package com.sasu.university_data.service.impl;


import com.sasu.university_data.entity.WorkPlace;
import com.sasu.university_data.mapper.WorkPlaceMapper;
import com.sasu.university_data.service.WorkPlaceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WorkPlaceServiceImpl implements WorkPlaceService {
    @Resource
    private WorkPlaceMapper workPlaceMapper;
    @Override
    public List<WorkPlace> queryWorkPlaceById( Integer id) {
        return workPlaceMapper.queryWorkPlaceById(id);
    }

    @Override
    public long count (String loc) {
        return workPlaceMapper.count(loc);
    }

    @Override
    public List<WorkPlace> selectByPage (String loc, Integer page, Integer pageSize ) {
        if (page <= 1) {
            page = 1;
        }
        if (pageSize <= 0) {
            pageSize = 10;
        }
        return workPlaceMapper.selectByPage(loc,(page - 1) * pageSize, pageSize);
    }

    @Override
    public boolean insert ( WorkPlace workPlace ) {
        return workPlaceMapper.insert(workPlace)>0;
    }

    @Override
    public boolean update ( WorkPlace workPlace ) {
        return workPlaceMapper.update(workPlace)>0;
    }

    @Override
    public boolean deleteById ( Integer wId ) {
        return workPlaceMapper.deleteById(wId)>0;
    }

    @Override
    public boolean deleteByIds ( int[] wIds ) {
        return workPlaceMapper.deleteByIds(wIds)>0;
    }
}
